package com.hillerscopy.controller;

import com.hillerscopy.service.CouponService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * Created by Igor.Leonov
 * Date: 4/12/12
 * Time: 4:42 AM
 */
@Controller
public class MainController {

    @Autowired
    private CouponService couponService;

    @RequestMapping(value = {"/", "/main"})
    private String mainPage(Model model) {
        model.addAttribute("coupons", couponService.loadCoupons());
        return "index";
    }

    @RequestMapping(value = "/addToCart", method = RequestMethod.POST)
    @ResponseBody
    private String addToCart(@RequestBody String id) {

        return "success";
    }
}
